/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package entidades;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author lcarou
 */
@Entity
@Table(name = "arsSUBFAMILIA")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "ArsSUBFAMILIA.findAll", query = "SELECT a FROM ArsSUBFAMILIA a"),
    @NamedQuery(name = "ArsSUBFAMILIA.findByFamilia", query = "SELECT a FROM ArsSUBFAMILIA a WHERE a.arsSUBFAMILIAPK.familia = :familia"),
    @NamedQuery(name = "ArsSUBFAMILIA.findByCodigo", query = "SELECT a FROM ArsSUBFAMILIA a WHERE a.arsSUBFAMILIAPK.codigo = :codigo"),
    @NamedQuery(name = "ArsSUBFAMILIA.findByDescripcion", query = "SELECT a FROM ArsSUBFAMILIA a WHERE a.descripcion = :descripcion")})
public class ArsSUBFAMILIA implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected ArsSUBFAMILIAPK arsSUBFAMILIAPK;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 100)
    @Column(name = "Descripcion")
    private String descripcion;
    @JoinColumn(name = "Familia", referencedColumnName = "Codigo", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private ArsFAMILIA arsFAMILIA;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "arsSUBFAMILIA")
    private Collection<ArsARTICULO> arsARTICULOCollection;

    public ArsSUBFAMILIA() {
    }

    public ArsSUBFAMILIA(ArsSUBFAMILIAPK arsSUBFAMILIAPK) {
        this.arsSUBFAMILIAPK = arsSUBFAMILIAPK;
    }

    public ArsSUBFAMILIA(ArsSUBFAMILIAPK arsSUBFAMILIAPK, String descripcion) {
        this.arsSUBFAMILIAPK = arsSUBFAMILIAPK;
        this.descripcion = descripcion;
    }

    public ArsSUBFAMILIA(String familia, String codigo) {
        this.arsSUBFAMILIAPK = new ArsSUBFAMILIAPK(familia, codigo);
    }

    public ArsSUBFAMILIAPK getArsSUBFAMILIAPK() {
        return arsSUBFAMILIAPK;
    }

    public void setArsSUBFAMILIAPK(ArsSUBFAMILIAPK arsSUBFAMILIAPK) {
        this.arsSUBFAMILIAPK = arsSUBFAMILIAPK;
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    public ArsFAMILIA getArsFAMILIA() {
        return arsFAMILIA;
    }

    public void setArsFAMILIA(ArsFAMILIA arsFAMILIA) {
        this.arsFAMILIA = arsFAMILIA;
    }

    @XmlTransient
    public Collection<ArsARTICULO> getArsARTICULOCollection() {
        return arsARTICULOCollection;
    }

    public void setArsARTICULOCollection(Collection<ArsARTICULO> arsARTICULOCollection) {
        this.arsARTICULOCollection = arsARTICULOCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (arsSUBFAMILIAPK != null ? arsSUBFAMILIAPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ArsSUBFAMILIA)) {
            return false;
        }
        ArsSUBFAMILIA other = (ArsSUBFAMILIA) object;
        if ((this.arsSUBFAMILIAPK == null && other.arsSUBFAMILIAPK != null) || (this.arsSUBFAMILIAPK != null && !this.arsSUBFAMILIAPK.equals(other.arsSUBFAMILIAPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entidades.ArsSUBFAMILIA[ arsSUBFAMILIAPK=" + arsSUBFAMILIAPK + " ]";
    }
    
}
